package algotithm.interview.欧科云链.test1;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

/**
 * @author zhouyanxiang
 * @Date 2021-04-2021/4/14-17:42
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

        String time = reader.readLine();
        String s = nextClosestTime(time);
        writer.write(s + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }

    public static String nextClosestTime(String time) {
        String[] arr = time.split(":");
        Set<Character> set = new HashSet<>();
        set.add(arr[0].charAt(0));
        set.add(arr[0].charAt(1));
        set.add(arr[1].charAt(0));
        set.add(arr[1].charAt(1));
        int hour = Integer.parseInt(arr[0]);
        int minute = Integer.parseInt(arr[1]);
        int minutes = hour * 60 + minute;
        for (int i = minutes + 1; i <= minutes + 24 * 60; i++) {
            String h = "" + (i % (24 * 60)) / 60;
            if (h.length() == 1) {
                h = "0" + h;
            }
            String m = "" + (i % (24 * 60)) % 60;
            if (m.length() == 1) {
                m = "0" + m;
            }
            if (set.contains(m.charAt(0)) && set.contains(m.charAt(1)) && set.contains(h.charAt(0)) && set.contains(h.charAt(1))) {
                return h + ":" + m;
            }
         }
         return "";
    }
}
